using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace IUPUI.StellarResults
{
	/// <summary>
	/// Represents an astronomical position.
	/// </summary>
	[Serializable]
	[TypeConverter(typeof(ExpandableObjectConverter))]
	public class Altazimuth : ININ.Xml.Serialization.XmlSerializationBase, 
		IComparable<Altazimuth>
	{
		#region Private Properties
		private double m_Altitude;
		private double m_Azimuth;
		#endregion Private Properties

		#region Public Properties
		/// <summary>
		/// Gets or sets the altitude.
		/// </summary>
		/// <value>The altitude.</value>
		[Category("Altazimuth")]
		[Description("Gets or sets the altitude.")]
		public double Altitude
		{
			get
			{
				return m_Altitude;
			}
			set
			{
				m_Altitude = value;
			}
		}

		/// <summary>
		/// Gets or sets the azimuth.
		/// </summary>
		/// <value>The azimuth.</value>
		[Category("Altazimuth")]
		[Description("Gets or sets the azimuth.")]
		public double Azimuth
		{
			get
			{
				return m_Azimuth;
			}
			set
			{
				m_Azimuth = value;
			}
		}
		#endregion Public Properties

		#region Constructors
		/// <summary>
		/// Initializes a new instance of the <see cref="Altazimuth"/> class.
		/// </summary>
		public Altazimuth()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Altazimuth"/> class.
		/// </summary>
		/// <param name="altitude">The altitude.</param>
		/// <param name="azimuth">The azimuth.</param>
		public Altazimuth(
			double altitude,
			double azimuth)
		{
			m_Altitude = altitude;
			m_Azimuth = azimuth;
		}
		#endregion Constructors

		#region Overrides
		/// <summary>
		/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </summary>
		/// <returns>
		/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </returns>
		/// <filterPriority>2</filterPriority>
		public override string ToString()
		{
			return String.Format("{0}, {1}",
				m_Altitude,
				m_Azimuth);
		}
		#endregion Overrides

		#region IComparable<Altazimuth> Members
		/// <summary>
		/// Compares the current object with another object of the same type.
		/// </summary>
		/// <param name="other">An object to compare with this object.</param>
		/// <returns>
		/// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the other parameter.Zero This object is equal to other. Greater than zero This object is greater than other.
		/// </returns>
		public int CompareTo(Altazimuth other)
		{
			int altitudeDiff = this.Altitude.CompareTo(other.Altitude);
			int azimuthDiff = this.Azimuth.CompareTo(other.Azimuth);

			if (altitudeDiff == 0 && azimuthDiff == 0)
			{
				return 0;
			}

			return azimuthDiff;
		}
		#endregion IComparable<Altazimuth> Members
	}
}
